package kuzmenkov.oip.service.impl;

import kuzmenkov.oip.common.LinkValidator;

import java.util.logging.Logger;

/**
 * Class represents an item of a list of contact links. It is used on
 * the Contact Page. E.g. a contact name is "Mr. Johnson", a link name is "Tel."
 * and a link value is "+375291234567"
 * User: Michael Kuzmenkov
 * Date: 27.03.2009
 * Time: 18:05:11
 */
public class LinkItem {
    private static Logger log = Logger.getLogger(LinkItem.class.getName());

    /**
     * A name of contact link. See above
     */
    private String name;
    /**
     * A value of a contact link. See above
     */
    private String value;
    /**
     * Indicates what a link value is a site reference
     */
    private boolean isSite;
    /**
     * Indicates what a link value is an email
     */
    private boolean isEmail;

    public LinkItem (String name, String value) {
        setName(name);
        setValue(value);
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getValue() {
        log.info("link item: name="+name+", value="+value+", isSite="+isSite+", isEmail="+isEmail);
        return value;
    }

    public void setValue(String value) {
        this.value = value;
        isSite = LinkValidator.validateSiteAddress(value.trim());
        isEmail = LinkValidator.validateEmailId(value.trim());
    }

    /**
     *
     * @see kuzmenkov.oip.service.impl.LinkItem#isEmail
     */
    public boolean getIsEmail () {
        return isEmail;
    }

    /**
     *
     * @see kuzmenkov.oip.service.impl.LinkItem#isSite
     */
    public boolean getIsSite () {
        return isSite;
    }
    
}
